Back to course home
0% completed
Vote For New Content
Longest Valid Parentheses (hard)
Problem Statement
You are given a string containing just the characters '(' and ')'. Your task is to find the length of the longest valid (well-formed) parentheses substring.
Example 1:
- Input:
"(())" - Expected Output:
4 - Justification: The entire string is a valid parentheses substring.
Example 2:
- Input:
")()())" - Expected Output:
4 - Justification: The longest valid parentheses substring is
"()()".
Example 3:
- Input:
"(()" - Expected Output:
2 - Justification: The longest valid parentheses substring is
"()".
Constraints:
- 0 <= s.length <= 3 * 104
s[i]is '(', or ')'.
Try it yourself
Try solving this question here:
Java
. . . .
Solution: Sudoku Solver
Solution: Longest Valid Parentheses
Mark as Completed
On this page
Problem Statement
Try it yourself